package project5;

import java.util.StringTokenizer;

/**
 * @author surabhi
 * @illustrator jason
 */
//This class just holds the information about the phrase and the frequencey
//This will be added to the Hashmap to indicate the 
public class PhraseItem implements Comparable<PhraseItem>
{
	String phrase;
	int frequency;

	public void display()
	{
		StringTokenizer st = new StringTokenizer(this.phrase,"+");
		StringBuffer printBuf = new StringBuffer();
		int count =0;
		while(st.hasMoreTokens())
		{
			count++;
			printBuf.append("\"" + st.nextToken() + "\",");
		}

		printBuf.append(">");

		if (count == 1)
		{
			System.out.print("#:" + this.frequency + "");
			System.out.print("\"" + this.phrase.substring(0, this.phrase.length() - 1) + "\""); 
		}
		else
		{
			System.out.print("#:" + this.frequency + "<" );
			System.out.print(printBuf.toString());
		}
	}

	public void diplay1()
	{
		System.out.print("#:" + this.frequency + "" );
		System.out.print("\"" + this.phrase.substring(0, this.phrase.length() - 1) + "\""); 
	}

	public int compareTo(PhraseItem obj)
	{
		PhraseItem pi = (PhraseItem) obj;

		Integer frq1 =  new Integer(frequency);
		Integer frq2 = new Integer (pi.frequency);

		return frq1.compareTo(frq2);
	}
}
